﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ShaboForm
{
    public partial class Login : Form
    {
        public static Login form1;
        public Login()
        {
            InitializeComponent();
            form1 = this;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string id = textBox1.Text;
                DataTable dt = DataAccessLayer.FindEmployee(id);
                if (dt.Rows.Count > 0)
                {
                    DataRow row = dt.Rows[0];
                    if (row["Permisions"].Equals(0))
                    {
                        AdminisrationsForm form = new AdminisrationsForm();
                        this.Hide();
                        form.Show();
                    }
                    else
                    {
                        MessageBox.Show("System does not support Workers permission level");
                    }
                }
                else
                {
                    MessageBox.Show("Worker does not exist in this company");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
